<template>
  <div class="app-container">
    <el-row>
      <el-col :span="6" class="tl-left-tree">
        <!-- 树 -->
        <el-input v-model="queryTreeParam.qry_name" placeholder="请输入页面" @keyup.enter.native="filterTree" ref="treeSearch">
          <el-button current-node-key="" slot="append" icon="el-icon-search" @click="filterTree"></el-button>
        </el-input>
        <el-scrollbar ref="treeScroll" :style="{ height: treeHeight + 'px' }" resizable-key="treeHeight" :resizable-reduce="20" :resizable-refs="['treeSearch']">
          <el-tree class="tl-tree" ref="tree" :data="treeData" node-key="id" :default-expand-all="true" highlight-current :expand-on-click-node="false" @node-click="doTreeQuery" :filter-node-method="filterTreeNode"></el-tree>
        </el-scrollbar>
      </el-col>
      <el-col :span="18">
        <el-row>
          <!-- 查询 -->
          <tl-search ref="search" :query-param="queryParam" @search="doQuery" v-if="isHeaderDisplay" :isDisplayDefaultSearch="false">
            <template slot="search">
              <el-form-item label="关联字段">
                 <el-input v-model="queryParam.qry_key" placeholder></el-input>
              </el-form-item>
              <el-form-item label="显示名称">
                <el-input v-model="queryParam.qry_title" placeholder></el-input>
              </el-form-item>
            </template>
          </tl-search>
        </el-row>
        <el-card>
          <el-row>
            <!-- 工具栏 -->
            <tl-toolbar ref="toolbar" @add="openAddDialog('editForm')" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :isDisplayDeleteBatch="selectedRowKeys.length > 0"> </tl-toolbar>
          </el-row>
          <el-row ref="selector">
            <!-- 列表选择 -->
            <div class="table-alert-div">
              <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
                <template slot="title">
                  已选择&nbsp;<a style="font-weight: bold;">{{ selectedRowKeys.length }}</a
                  >项&nbsp;&nbsp;
                  <a style="font-weight: bold;margin-left: 24px" @click="doClearSelected">全部清空</a>
                </template>
              </el-alert>
            </div>
          </el-row>
          <el-row>
            <el-table ref="mainTable" class="tl-table" :height="tableHeight" resizable-key="tableHeight" :resizable-reduce="42" :resizable-refs="['search', 'toolbar', 'selector', 'pager']"  v-loading="loading" :data="datas" style="width: 100%;" @selection-change="doSelectChange" @sort-change="doSortChange" row-key="id" border fit :row-class-name="doChangeRowClassName" :default-sort="{ prop: 'dept_code', order: 'ascending' }">
              <el-table-column type="selection" width="55px"> </el-table-column>
              <el-table-column type="index" label="序号" width="55px" align="center"> </el-table-column>
              <el-table-column prop="title" label="显示名称" min-width="16.5%" sortable="custom" sort-by="title" align="left"></el-table-column>
              <el-table-column prop="key" label="关联字段" min-width="14.5%" sortable="key" sort-by="key" align="center"></el-table-column>
              <el-table-column prop="dispdatatype" label="字段类型" min-width="14.5%" sortable="datatype" sort-by="datatype" align="center"></el-table-column>
              <el-table-column prop="dispextendfield1" label="空值隐藏" min-width="14.5%" sortable="extendfield1" sort-by="extendfield1" align="center"></el-table-column>
              <el-table-column prop="sortcode" label="排序" min-width="14.5%" sortable="sortcode" sort-by="sortcode" align="center"></el-table-column>
              <el-table-column prop="expression" label="字段表达式" min-width="16.5%" sortable="expression" sort-by="expression" align="center"></el-table-column>
              <!-- <el-table-column prop="description" label="备注" min-width="9.5%" sortable="custom" sort-by="description" align="left"></el-table-column> -->
              <el-table-column label="操作" width="180px" header-align="center" align="center" v-slot="slotProps" fixed="right">
                <el-button type="text" icon="el-icon-edit" @click="openEditDialog('editForm', slotProps.row.id)"> 编辑</el-button>
                <el-button type="text" icon="el-icon-delete" @click="doDelete(slotProps.row.id)">删除</el-button>
                <!-- <el-button type="text" icon="el-icon-view" @click="openViewDialog('editForm', slotProps.row.id)">查看</el-button> -->
              </el-table-column>
            </el-table>
          </el-row>
          <!-- 列表分页 -->
          <el-row class="pagebar" ref="pager">
            <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
          </el-row>
        </el-card>
      </el-col>
      <!-- 编辑界面 -->
      <tl-edit ref="editForm" @refresh="doAllRefresh" :pagetabid="this.selectTreeNode.id" :enabledList="this.codeModel.enabledList" :datatypeList="this.codeModel.datatypeList" :hiddenList="this.codeModel.hiddenList"></tl-edit>
    </el-row>
  </div>
</template>
<script>
/** mixins */
import { mixin_tree_list } from "@tapui/mixins/mixin_tree_list"
/** 子组件 */
import tlEdit from "./edit"
import { getAction, putAction, postAction } from "@tapui/utils/http"
import tlSearch from "@tapui/components/Tap/List/ListSearch"
import tlToolbar from "@tapui/components/Tap/List/ListToolBar"
export default {
  name: "pageElementMgt",
  components: { tlEdit, tlSearch, tlToolbar },
  mixins: [mixin_tree_list],
  data() {
    return {
       urlPrefix: "/app/appPageItems/",
        url: {
          queryCodeList: "/app/appPageItems/dataCodeList",
          queryTree: "app/appPageItems/queryTreeList?qry_enabled=1",
          deleteBatch: "app/appPageItems/deleteBatch",
          exportExcel: "app/appPageItems/exportExcel"
        },
        datatypeList: [],
        hiddenList: [],
        enabledList: []
      }
  },
  methods: {
    // 获取编码值列表
    // queryDataCodeList(parameter) {
    //   getAction(this.url.queryDataCodeList, parameter).then((res) => {
    //     if (res.success) {
    //       this.datatypeList = res.result.datatypeList
    //       this.hiddenList = res.result.hiddenList
    //       this.enabledList = res.result.enabledList
    //     } else {
    //       this.$tap.alert(res.message)
    //     }
    //   })
    // }
  },
  mounted() {
    // this.queryDataCodeList({})
  }
}
</script>
<style lang="scss" scoped></style>
